module directx.d3dcompiler;
public import directx.com;
public import directx.d3dcommon;
alias directx.com.uuidof uuidof;

const D3DCOMPILE_DEBUG =                         (1 << 0);
const D3DCOMPILE_SKIP_VALIDATION =               (1 << 1);
const D3DCOMPILE_SKIP_OPTIMIZATION =             (1 << 2);
const D3DCOMPILE_PACK_MATRIX_ROW_MAJOR =         (1 << 3);
const D3DCOMPILE_PACK_MATRIX_COLUMN_MAJOR =      (1 << 4);
const D3DCOMPILE_PARTIAL_PRECISION =             (1 << 5);
const D3DCOMPILE_FORCE_VS_SOFTWARE_NO_OPT =      (1 << 6);
const D3DCOMPILE_FORCE_PS_SOFTWARE_NO_OPT =      (1 << 7);
const D3DCOMPILE_NO_PRESHADER =                  (1 << 8);
const D3DCOMPILE_AVOID_FLOW_CONTROL =            (1 << 9);
const D3DCOMPILE_PREFER_FLOW_CONTROL =           (1 << 10);
const D3DCOMPILE_ENABLE_STRICTNESS =             (1 << 11);
const D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY  =(1 << 12);
const D3DCOMPILE_IEEE_STRICTNESS  =              (1 << 13);
const D3DCOMPILE_OPTIMIZATION_LEVEL0 =           (1 << 14);
const D3DCOMPILE_OPTIMIZATION_LEVEL1 =           0;
const D3DCOMPILE_OPTIMIZATION_LEVEL2 =           ((1 << 14) | (1 << 15));
const D3DCOMPILE_OPTIMIZATION_LEVEL3 =           (1 << 15);
const D3DCOMPILE_RESERVED16 =                    (1 << 16);
const D3DCOMPILE_RESERVED17 =                    (1 << 17);
const D3DCOMPILE_WARNINGS_ARE_ERRORS =           (1 << 18);


const D3DCOMPILE_EFFECT_CHILD_EFFECT =             (1 << 0);
const D3DCOMPILE_EFFECT_ALLOW_SLOW_OPS =           (1 << 1);

extern(Windows){
    HRESULT
    D3DCompile( LPCVOID pSrcData,
                SIZE_T SrcDataSize,
                LPCSTR pSourceName,
                const D3D_SHADER_MACRO* pDefines,
                ID3DInclude pInclude,
                LPCSTR pEntrypoint,
                LPCSTR pTarget,
                UINT Flags1,
                UINT Flags2,
                ID3DBlob* ppCode,
                ID3DBlob* ppErrorMsgs);
    
    
    HRESULT
    D3DPreprocess( LPCVOID pSrcData,
                  SIZE_T SrcDataSize,
                  LPCSTR pSourceName,
                  const D3D_SHADER_MACRO* pDefines,
                  ID3DInclude pInclude,
                  ID3DBlob* ppCodeText,
                  ID3DBlob* ppErrorMsgs);
    
    HRESULT
    D3DGetDebugInfo( LPCVOID pSrcData,
                     SIZE_T SrcDataSize,
                     ID3DBlob* ppDebugInfo);
    
    
    HRESULT
    D3DReflect(LPCVOID pSrcData,
               SIZE_T SrcDataSize,
	           REFIID pInterface,
               void* ppReflector);
}


const D3D_DISASM_ENABLE_COLOR_CODE            = 0x00000001;
const D3D_DISASM_ENABLE_DEFAULT_VALUE_PRINTS  = 0x00000002;
const D3D_DISASM_ENABLE_INSTRUCTION_NUMBERING = 0x00000004;
const D3D_DISASM_ENABLE_INSTRUCTION_CYCLE     = 0x00000008;
const D3D_DISASM_DISABLE_DEBUG_INFO           = 0x00000010;

extern(Windows){

    HRESULT 
    D3DDisassemble( LPCVOID pSrcData,
                    SIZE_T SrcDataSize,
                    UINT Flags,
                    LPCSTR szComments,
                    ID3DBlob* ppDisassembly);
    
    /*
    HRESULT WINAPI
    D3DDisassemble10Effect(__in interface ID3D10Effect *pEffect, 
                           __in UINT Flags,
                           __out ID3DBlob** ppDisassembly);
    */

    HRESULT
    D3DGetInputSignatureBlob( LPCVOID pSrcData,
                              SIZE_T SrcDataSize,
                              ID3DBlob* ppSignatureBlob);

    HRESULT
    D3DGetOutputSignatureBlob( LPCVOID pSrcData,
                               SIZE_T SrcDataSize,
                               ID3DBlob* ppSignatureBlob);

    HRESULT
    D3DGetInputAndOutputSignatureBlob( LPCVOID pSrcData,
                                       SIZE_T SrcDataSize,
                                       ID3DBlob* ppSignatureBlob);
    
}

enum D3DCOMPILER_STRIP_FLAGS{
    D3DCOMPILER_STRIP_REFLECTION_DATA = 1,
    D3DCOMPILER_STRIP_DEBUG_INFO      = 2,
    D3DCOMPILER_STRIP_TEST_BLOBS      = 4,
    D3DCOMPILER_STRIP_FORCE_DWORD     = 0x7fffffff,
}

extern(Windows){
    HRESULT
    D3DStripShader( LPCVOID pShaderBytecode,
                    SIZE_T BytecodeLength,
                    UINT uStripFlags,
                    ID3DBlob* ppStrippedBlob);
}

enum D3D_BLOB_PART{
    D3D_BLOB_INPUT_SIGNATURE_BLOB,
    D3D_BLOB_OUTPUT_SIGNATURE_BLOB,
    D3D_BLOB_INPUT_AND_OUTPUT_SIGNATURE_BLOB,
    D3D_BLOB_PATCH_CONSTANT_SIGNATURE_BLOB,
    D3D_BLOB_ALL_SIGNATURE_BLOB,
    D3D_BLOB_DEBUG_INFO,
    D3D_BLOB_LEGACY_SHADER,
    D3D_BLOB_XNA_PREPASS_SHADER,
    D3D_BLOB_XNA_SHADER,

    // Test parts are only produced by special compiler versions and so
    // are usually not present in shaders.
    D3D_BLOB_TEST_ALTERNATE_SHADER = 0x8000,
    D3D_BLOB_TEST_COMPILE_DETAILS,
    D3D_BLOB_TEST_COMPILE_PERF,
}

extern(Windows){
    HRESULT
    D3DGetBlobPart( LPCVOID pSrcData,
                    SIZE_T SrcDataSize,
                    D3D_BLOB_PART Part,
                    UINT Flags,
                    ID3DBlob* ppPart);
}

struct _D3D_SHADER_DATA
{
    LPCVOID pBytecode;
    SIZE_T BytecodeLength;
}

alias _D3D_SHADER_DATA D3D_SHADER_DATA;

const D3D_COMPRESS_SHADER_KEEP_ALL_PARTS = 0x00000001;


extern(Windows){
    HRESULT
    D3DCompressShaders( UINT uNumShaders,
                        D3D_SHADER_DATA* pShaderData,
                        UINT uFlags,
                        ID3DBlob* ppCompressedData);
    HRESULT
    D3DDecompressShaders( LPCVOID pSrcData,
                          SIZE_T SrcDataSize,
                          UINT uNumShaders,	      
                          UINT uStartIndex,
                          UINT* pIndices,
                          UINT uFlags,
                          ID3DBlob* ppShaders,
		                  UINT* pTotalShaders);

    HRESULT
    D3DCreateBlob(SIZE_T Size,
                  ID3DBlob* ppBlob);
}